<?php echo form_tag('componentsbyclient/save', array(
  'id'        => 'sf_admin_edit_form',
  'name'      => 'sf_admin_edit_form',
  'multipart' => true,
)) ?>

<?php echo object_input_hidden_tag($components_by_client, 'getId') ?>

<fieldset id="sf_fieldset_none" class="">

<div class="form-row">
  <label for="components_by_client_bom_id" class="required">BOM:</label>
    <div class="content">    
    <input type="text" name ="components_by_client[bom_id]" size = "45" disabled value ="<? echo $components_by_client->getBom()?>"></div>    
</div>
<div class="form-row">
  <label for="components_by_client_bom_id" class="required">Project:</label>
  <div class="content">
  <input type="text" name ="components_by_client[project_id]" size = "45"  disabled value ="<? echo $components_by_client->getProject()?>"></div>    
</div>
<div class="form-row">
  <label for="components_by_client_bom_id" class="required">Client:</label>
  <div class="content">
  <input type="text" name ="components_by_client[client_id]"  size = "45"  disabled value ="<? echo $components_by_client->getClient()?>"></div>    
</div>

<div class="form-row">
  <label for="components_by_client_bom_id" class="required">Status:</label>
  <div class="content">
  <input type="text" name ="components_by_client[status]"  size = "10"  disabled value ="<? echo CommonValues::$gCBCStatus['value'][$components_by_client->getStatus()]?>"></div>    
</div>

<table id ='added_components' "cellspacing="0" class="sf_admin_list">
<thead>
<tr>
      <th id="sf_admin_list_th_productcode" width="25%">Product Code</th>
      <th id="sf_admin_list_th_description" width="35%">Description</th>
      <th id="sf_admin_list_th_description">Qty Needed</th>       
      <th id="sf_admin_list_th_description" >Qty In</th>      
      <th id="sf_admin_list_th_description">Qty Out</th>      
      <th id="sf_admin_list_th_description" >Qty Unused</th>
</tr>
</thead>
<!--show component here-->
<?php  
if ($components_by_client->getComponentgroupId()){
    $c = new Criteria();
    $c->add(ComponentsPeer::COMPONENTGROUP_ID , $components_by_client->getComponentgroupId());
    $c->addAscendingOrderByColumn(ComponentsPeer::COMPONENT_ID);
    $componentsList = ComponentsPeer::doSelect($c);
}
if (isset($components_by_client->rowIds) && count($components_by_client->rowIds)) {
    foreach ($components_by_client->rowIds as $key=>$id) { 
        $component= ComponentPeer::retrieveByPK($id);
        ?>
        <tr class="sf_admin_row_<?php echo $key%2?>">
            <input type="hidden" name="rowIds[]" id ="rowIds"  class = "ExistComponents" value="<? echo $component->getId()?>"/>
            <td><?echo $component->getProductcode()?></td>
            <td><?echo $component->getDescription()?></td>
            <td><input type="hidden" name="qtys[]" id ="qtys" size="5" class="QTYS"   value ="<?echo $components_by_client->qtys[$key]?>">
            <input type="text" name="qty1s[]" id ="qty1s" size="5" class="QTY1S"  disabled value ="<?echo $components_by_client->qtys[$key]?>"></td>
            <td><input type="text" name="qty2s[]" id ="qty2s" size="5" class="QTY2S"  value ="<?echo $components_by_client->qty2s[$key]?>"></td>
            <td><input type="text" name="qty3s[]" id ="qty3s" size="5" class="QTY3S"  value ="<?echo $components_by_client->qty3s[$key]?>"></td>
            <td><input type="text" name="qty4s[]" id ="qty4s" size="5" class="QTY4S"  value ="<?echo $components_by_client->qty4s[$key]?>"></td>
        </tr>
<?php } } elseif (isset($componentsList) && count($componentsList)) {
    foreach ($componentsList as $key=>$components) { 
        $component= ComponentPeer::retrieveByPK($components->getComponentId());
        ?>
        <tr class="sf_admin_row_<?php echo $key%2?>">
            <input type="hidden" name="rowIds[]" id ="rowIds"  class = "ExistComponents" value="<? echo $component->getId()?>"/>
            <td><?echo $component->getProductcode()?></td>
            <td><?echo $component->getDescription()?></td>
            <td><input type="hidden" name="qtys[]" id ="qtys" size="5" class="QTYS"   value ="<?echo $components->getQty1()?>">
            <input type="text" name="qty1s[]" id ="qty1s" size="5" class="QTY1S"  disabled value ="<?echo $components->getQty1()?>"></td>
            <td><input type="text" name="qty2s[]" id ="qty2s" size="5" class="QTY2S"  value ="<?echo $components->getQty2()?>"></td>
            <td><input type="text" name="qty3s[]" id ="qty3s" size="5" class="QTY3S"  value ="<?echo $components->getQty3()?>"></td>
            <td><input type="text" name="qty4s[]" id ="qty4s" size="5" class="QTY4S"  value ="<?echo $components->getQty4()?>"></td>
        </tr>
<?php } }?>
</table>


</fieldset>

<?php include_partial('edit_actions', array('components_by_client' => $components_by_client)) ?>

</form>